{extend name="base/common"}

{block name="style"}
<link rel="stylesheet" href="/static/datepicker/bootstrap-datetimepicker.min.css">
<style>
    .mail-search{max-width: 100% !important;}
    .input-group{float: left !important;}
    label{padding-top: 7px;}
    .btn-sm{height: 34px;}
    .exported{float: right;}
</style>
{/block}

{block name="page-header"}

{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="mail-box-header">
                <h2>考勤打卡 / 考勤上班</h2>
                <div class="mail-tools tooltip-demo m-t-md">
                    <form method="get" action="" class="mail-search" id="form">
                        <div class="input-group col-lg-3">
                            <div class="col-lg-4 text-right control-label">
                                <label>选择时间:</label>
                            </div>
                            <div class="col-lg-8">
                                <input type="text" placeholder="请选择开始时间" class="form-control form_title datetimepicker" name="time" value="{$time}">
                            </div>
                        </div>
                        <!--<div class="input-group col-lg-3">-->
                            <!--<div class="col-lg-4 text-right control-label">-->
                                <!--<label>结束时间:</label>-->
                            <!--</div>-->
                            <!--<div class="col-lg-8">-->
                                <!--<input type="text" placeholder="请选择结束时间" class="form-control form_title datetimepicker" name="end_time" value="">-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="input-group col-lg-4">
                            <!--<input type="text" class="form-control form_title" name="search" placeholder="搜索用户名">-->
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i> 搜索</button>
                            </div>
                        </div>
                    </form>
                </div>
                <button data-url="{:Url('Attendance/export1')}" class="btn btn-primary btn-sm exported" ><i class="fa fa-upload"></i> 记录导出</button>
            </div>
            <div class="mail-box">
                <table class="table table-hover table-mail">
                    <thead>
                    <tr>
                        <th></th>
                        <th>部门名称</th>
                        <th>用户名</th>
                        <th>考勤状态</th>
                        <th>考勤时间</th>
                        <th>上报人</th>
                        <th>上报时间</th>
                    </tr>
                    </thead>

                    <tbody>
                    {volist name="list" id="vo"}
                    <tr>
                        <td class="check-mail"></td>
                        <td>{$vo.departmentname}</td>
                        <td>{$vo.username}</td>
                        {switch name="$vo.status" }
                        {case value="1" }<td style="color: #2081f7;">{$vo.status_text}</td>{/case}
                        {case value="2"}<td style="color: #4dbc73;">{$vo.status_text}</td>{/case}
                        {default /}<td style="color: #fac037;">{$vo.status_text}</td>
                        {/switch}
                        <td>{$vo.attendance_time}</td>
                        <td>{$vo.report_user|default='-'}</td>
                        <td>{$vo.report_time|default='-'}</td>
                    </tr>
                    {/volist}
                    </tbody>

                </table>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="/admin/js/plugins/iCheck/icheck.min.js"></script>
<script>
    highlight_subnav("{:Url('Attendance/work')}");

    $(document).ready(function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $(".check-all").on("ifChanged",function(){
            $("tbody").find(".ids").iCheck("toggle");
        });
    });
</script>
<!--时间日历-->
<script src="/static/datepicker/bootstrap-datetimepicker.js"></script>
<script>
    $(function(){
        //    时间日历
        $( ".datetimepicker" ).datetimepicker( {
            language:  'cn',
            format: 'yyyy-mm-dd',
            minView: 2,
            forceParse: false,
            todayBtn: true,
            autoclose: true,
            todayHighlight: 1,
            minuteStep: 5,
            initialDate: new Date(),//初始化当前日期

        });
        //    单选按钮
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });

        $(document).on("click", ".exported", function () {
            var url = $(".exported").attr("data-url");
            $.ajax({
                type:'post',
                url: url,
                data:{
                    time: $("input[name='time']").val(),
                    // end_time: $("input[name='end_time']").val(),
                    // search: $("input[name='search']").val()
                },
                success: function (data) {
                    var msg = JSON.parse(data);
                    console.log(msg)
                    if(msg.code == 0) {
                        var url = msg.url.substr(1);
                        window.open(url, "_blank");
                        warning({shortCutFunction:'success',msg:'文件导出成功'});
                    }else {
                        warning({shortCutFunction:'error',msg:'文件导出失败'});
                    }

                }
            })
        })
    });

</script>
{/block}
